package com.ssy.lingxi.settle.accounts.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 通用枚举
 * @author 伍将
 * @date 2020/8/17 20:18
 * @version 2.0.0
 */
public enum CommonBooleanEnum {

    /**
     * 否 - 0
     */
    NO(0, "否"),

    /**
     * 是 - 1
     */
    YES(1, "是");

    private final Integer code;
    private final String message;

    CommonBooleanEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(CommonBooleanEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(NO).getMessage();
    }
}
